package com.shunda.pay.controller;

import com.shunda.common.core.controller.BaseController;
import com.shunda.common.core.domain.AjaxResult;
import com.shunda.pay.service.IWeChatPayCallBackService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 微信回调相关的接口
 */
@RestController
@RequestMapping("/wechat/callback")
public class WeChatPayCallBackController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(WeChatPayCallBackController.class);

    @Autowired
    private IWeChatPayCallBackService weChatPayCallBackService;

    /**
     * 订单支付回调
     *
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/wxOrderCallBack")
    public AjaxResult wxOrderCallBack(HttpServletRequest request, HttpServletResponse response) {
        log.info("订单支付回调");
        Map<String, String> stringStringMap = weChatPayCallBackService.wxOrderCallBack(request, response);
        return success(stringStringMap);
    }

    /**
     * 提现回调
     *
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/transferCallBack")
    public AjaxResult transferCallBack(HttpServletRequest request, HttpServletResponse response) {
        log.info("提现回调");
        Map<String, String> stringStringMap = weChatPayCallBackService.transferCallBack(request, response);
        return success(stringStringMap);
    }

}
